#include "stdlib.h"
#include "stdio.h"
#include "string.h"

#include "automate.H"

void initialise_automate(automate & Auto, const int etat_initial, const int * etat_final,const char * mot_ref,const int nb_etat)
{
    Auto.mot =(char*) malloc(sizeof(char)*(strlen(mot_ref)+1));
    int i = 0;
    while (mot_ref[i] != '\0')
    {
        Auto.mot[i] = mot_ref[i];
    }
    Auto.etat_courant = etat_initial;
    Auto.etat_initial = etat_initial;
    Auto.etat_final = (int *)malloc(sizeof(int)*nb_etat);
    for (i=0; i<nb_etat; i++)
    {
        Auto.etat_final[i] = etat_final[i];
    }
}


void fonction_transition_fini_par_a(automate & Auto, const int lettre)
{
    switch(lettre)
    {
        case 0:
            Auto.etat_courant = 0;
        case 1:
            Auto.etat_courant = 1;
        default :
            Auto.etat_courant = 2;
    }
}
